package cn.itsource.ymcc.client.fallback;

import cn.itsource.ymcc.client.CourseFeignClient;
import cn.itsource.ymcc.result.JSONResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class CourseFeignClientFallbackFactory implements FallbackFactory<CourseFeignClient> {
    @Override
    public CourseFeignClient create(Throwable throwable) {
        return new CourseFeignClient(){

            @Override
            public JSONResult getCourseInfo(Long id) {
                throwable.printStackTrace();
                return JSONResult.error("课程查询失败");
            }

            @Override
            public JSONResult getCourseInfos(List<Long> courseIds) {
                throwable.printStackTrace();
                return JSONResult.error("课程查询失败");
            }
        };
    }
}
